package xuwei_k

case class CommitId(id:String)

case class Commit(project:GitProject,id:CommitId,url:String,message:String){
  
  lazy val shortUrl = Googl.getShortUrl(url)
  
  lazy val tweetString = 
    Seq(shortUrl,project.hashtag,message).mkString(" ").take(140).replace("@"," ")

}

object Commit{
  def apply(project:GitProject)(data:xml.Node):Commit =
    Commit(
      project
      ,CommitId( (data \ "id" ).text )
      , "http://github.com" + (data \ "url" ).text
      ,(data \ "message" ).text
    )
}
